package pers.vinsonws.jianghu.serverspring.entity;


import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * @auther vinsonws
 * @date 2018/10/30 19:22
 */
@Entity
@Table(name="chatrooms")
public class ChatRooms {
    @Id
    @Column(name = "id")
    private int id;

    @Column(name = "name")
    private String name;

    @Column(name = "master")
    private int masterId;

    @ManyToMany(targetEntity = Users.class,fetch=FetchType.LAZY)
    @JoinTable(name = "chatroom_user",
            joinColumns = @JoinColumn(name = "chatroom_id"),
            inverseJoinColumns = @JoinColumn(name = "user_id"))
    private Set<Users> users = new HashSet<>();

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMasterId() {
        return masterId;
    }

    public void setMasterId(int masterId) {
        this.masterId = masterId;
    }

    public Set<Users> getUsers() {
        return users;
    }

    public void setUsers(Set<Users> users) {
        this.users = users;
    }

    @Override
    public String toString() {
        return "ChatRooms{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", masterId=" + masterId +
                '}';
    }
}
